-- godfather_storage
-- created by chendh
-- 地牢格子：宇宙教父的储藏器

-- 随机一下数组/两两交换
local function randomTable(arr)
    for oriIndex, value in pairs(arr) do
        local toIndex = math.random(#arr);
        local temp = arr[toIndex];
        arr[toIndex] = arr[oriIndex];
        arr[oriIndex] = temp;
    end
    return arr;
end

return {
    autoFight = function(grid)
        local dungeonId = DungeonM.getDungeonId();
        local layer = DungeonM.currentLayer();
        if DungeonBossM.isBossLayer(dungeonId, layer)
            and not DungeonM.isAllMonsterDead() then
            -- boss层要等boss被击杀
            return false;
        end

        local pos = grid:getPos();

        -- 通用
        if DungeonInstanceM.isInInstance() then
            -- 如果在副本中，走副本奖励流程
            return DungeonActionM.go("take_instance_bonus", pos);
        else
            return DungeonActionM.go("do_building_bonus", pos);
        end

        return false;
    end,
};
